Skip to content

Save and restore settings window size and position - #1197

Open
Yasinnet0 wants to merge 4 commits into
unchihugo:masterfrom
Yasinnet0:remember-window-size
Open

Yasinnet0 wants to merge 4 commits into
unchihugo:masterfrom
Yasinnet0:remember-window-size

Conversation

@Yasinnet0

@Yasinnet0 Yasinnet0 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds window size, position, and maximized state persistence to the Settings Window across app sessions.

Motivation

Previously, opening the Settings Window always reset its size to the default 900x700 and opened at the center of the screen, discarding any resizing or repositioning done by the user.

Closes #908

Type of Change

  • Feature

What Changed

  • ViewModels/UserSettings.cs:
    • Added persistent properties: SettingsWindowWidth, SettingsWindowHeight, SettingsWindowLeft, SettingsWindowTop, and SettingsWindowState.
  • SettingsWindow.xaml.cs:
    • Switched startup position mode to WindowStartupLocation.Manual.
    • Added GetWorkAreaForBounds(...) helper using MonitorUtil to calculate DIP-scaled work areas across multi-monitor setups.
    • Clamped target window dimensions and coordinates within the active monitor's work area, preventing the window from clipping behind taskbars or opening off-screen.
    • Centered window on initial startup (when coordinates are NaN).
    • Added listeners to LocationChanged, SizeChanged, and StateChanged to track changes while in Normal state.
    • Handled WindowState.Maximized state restoration while preserving normal restore bounds.
    • Ensured final window dimensions or RestoreBounds are flushed in SettingsWindow_Closing.

Additional Information

  • Verified that multi-monitor setups with differing DPI scaling clamp coordinates cleanly within visible work areas without disappearing off-screen.
  • Debounced settings serialization ensures window movement and resizing do not produce excessive disk writes.
  • A user toggle in the settings UI can be introduced in a follow up PR to allow users to disable this persistence behavior if desired.

Checklist

  • Code changes are manually tested and working.
  • Formatting and naming are consistent with the project.
  • Self-review of changes is done.
  • AI tools were used (if yes, I reviewed and fully understand the changes myself).

@github-actions github-actions Bot added the SettingsWindow Changes to SettingsWindow or settings pages not related to flyouts/widgets label Oct 8, 2026
@Yasinnet0 Yasinnet0 changed the title Remember settings window size and position Save and restore settings window size and position Oct 8, 2026

@unchihugo unchihugo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Yasinnet0, thanks for looking to contribute. I wonder if there's a more native implementation than what we're doing here? It's quite a lot of code for what should be a simple patch/toggle.

@Yasinnet0

Copy link
Copy Markdown
Contributor Author

Hi @Yasinnet0, thanks for looking to contribute. I wonder if there's a more native implementation than what we're doing here? It's quite a lot of code for what should be a simple patch/toggle.

Hi you were right i did overdone some parts, in new commit i removed constantly saving size and position and it just saves them upon window close
and i added a part to MonitorUtil soo it finds the right monitor and it gets the workarea soo if the window gets closed outside of screen at bottom after reopening some parts doesn't go behind the taskbar and converts the hardware pixels to WPF
DIPs according to the monitors display scale (DPI)

@Yasinnet0

Copy link
Copy Markdown
Contributor Author

I think it's done now
Feel free to let me know if you have any ideas for further optimizations or a better implementation, or if this looks good to merge

@unchihugo unchihugo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Thank you for the modifications!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SettingsWindow Changes to SettingsWindow or settings pages not related to flyouts/widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Remember Settings Window size across sessions

2 participants